<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>统计字符串中字母个数或统计最多字母数</title>
	<script type="text/javascript">
		var str = "aaaabbbccccddfgh我的你的他的";
		var obj  = {};
		for(var i=0;i < str.length;i++){
		    var v = str.charAt(i);
		    if(obj[v] && obj[v].value == v){
		        obj[v].count = ++ obj[v].count;
		    }else{
		        obj[v] = {};
		        obj[v].count = 1;
		        obj[v].value = v;
		    }
		}
		for(key in obj){
		    document.write(obj[key].value +'='+obj[key].count+' '); // a=4  b=3  c=4  d=2  f=1  g=1  h=1 
		}

	</script>
</head>
<body>
	
</body>
</html>